package com.dmooo.yxmmerchant.view.presenter;

import android.content.Context;

import com.common.mvpbase.BasePresenter;
import com.common.net.listener.HttpOnNextListener;
import com.dmooo.yxmmerchant.view.contract.RegisterContract;
import com.dmooo.yxmmerchant.view.model.RegisterModel;

import java.io.File;

public class RegisterPrestener extends BasePresenter<RegisterContract.RegisterView> implements RegisterContract.RegisterPtr {
    private RegisterModel model;
    public RegisterPrestener(RegisterContract.RegisterView view, Context context) {
        super(view);
        model = new RegisterModel(context);
    }
    @Override
    public void getPhoneCode(String phone) {
        model.getPhoneCode(phone, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.getPhoneSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void doRegister(String phone, String code, String pwd) {
        model.doRegister(phone, code, pwd, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.registerSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void submitMerchantProfile(String phone, String merchant_type, String merchant_name, File avatar, String service_tel, String business_day_begin, String business_day_end, String province, String city, String county) {
        model.submitMerchantProfile(phone, merchant_type, merchant_name, avatar, service_tel, business_day_begin, business_day_end, province, city, county, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.submitProfileSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void submitId(String phone, File business_license, String artificial_person, String artificial_person_id_num, File artificial_person_id_img1, File artificial_person_id_img2) {
        model.submitId(phone, business_license, artificial_person, artificial_person_id_num, artificial_person_id_img1, artificial_person_id_img2, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.submitIdSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }
}
